package com.pzhu.service.impl;

import com.pzhu.dao.LoginDao;
import com.pzhu.dao.impl.LoginDaoImpl;
import com.pzhu.pojo.User;
import com.pzhu.service.LoginService;
import org.junit.Test;

public class LoginServiceImpl implements LoginService {

    @Test
    public void test(){
        checkUser("张三","111");
    }
//    添加Dao层成员变量
    private LoginDao loginDao = new LoginDaoImpl();

    public boolean checkUser(String uname,String pwd) {
//      封装数据
        User userInPut = new User(uname, pwd);
//      调用Dao层查询数据
        User userSelect = loginDao.checkUser(userInPut);
//      判断数据是否匹配 如果没有数据，则直接跳过匹配
        if (userSelect!=null){
//            equals密码判断
            if (userInPut.getPwd().equals(userSelect.getPwd())){
                return true;
            }
        }
        return false;
    }
}
